package netuser

import (
	"gorm.io/gorm"
	"wwp.space/NetSim/ndatabase"
)

type User struct {
	gorm.Model
	Account     string `form:account`
	Password    string `form:password`
	Username    string `form:"username"`
	Phonenumber string `form:"phone_number"`
	Age         int    `form:"age"`
	Gender      int    `form:"gender"`
}

func (User) TableName() string {
	return "net_user" // 自定义表名
}

func init() {
	if ndatabase.Db.Migrator().HasTable(&User{}) {
		return
	}

	err := ndatabase.Db.AutoMigrate(&User{})
	if err != nil {
		panic("AutoMigrate failed:" + err.Error())
	}

	ndatabase.Db.Create(&User{
		Account:     "1001001",
		Password:    "123456",
		Username:    "登录小助手",
		Phonenumber: "10086",
		Age:         24,
		Gender:      1,
	})

}
